#Boa:Dialog:register

import wx
from common import *
import database
def create(parent):
    return register(parent)

[wxID_REGISTER, wxID_REGISTERAGE, wxID_REGISTERBRAND, wxID_REGISTERCANCEL, 
 wxID_REGISTERCARCOLOR, wxID_REGISTERCARID, wxID_REGISTERCOMPANY, 
 wxID_REGISTEREMAIL, wxID_REGISTERLICENSEID, wxID_REGISTERNAME, 
 wxID_REGISTERNOTEBOOK1, wxID_REGISTERPANEL1, wxID_REGISTERPANEL2, 
 wxID_REGISTERPANEL3, wxID_REGISTERPANEL4, wxID_REGISTERPANEL5, 
 wxID_REGISTERPANEL6, wxID_REGISTERPHONE, wxID_REGISTERPWD, 
 wxID_REGISTERSCROLLEDWINDOW1, wxID_REGISTERSCROLLEDWINDOW2, wxID_REGISTERSEX, 
 wxID_REGISTERSTATICTEXT1, wxID_REGISTERSTATICTEXT10, 
 wxID_REGISTERSTATICTEXT11, wxID_REGISTERSTATICTEXT12, 
 wxID_REGISTERSTATICTEXT2, wxID_REGISTERSTATICTEXT3, wxID_REGISTERSTATICTEXT4, 
 wxID_REGISTERSTATICTEXT5, wxID_REGISTERSTATICTEXT6, wxID_REGISTERSTATICTEXT7, 
 wxID_REGISTERSTATICTEXT8, wxID_REGISTERSTATICTEXT9, wxID_REGISTERSUBMIT, 
] = [wx.NewId() for _init_ctrls in range(35)]

class register(wx.Dialog):
    def _init_coll_notebook1_Pages(self, parent):
        # generated method, don't edit

        parent.AddPage(imageId=-1, page=self.scrolledWindow1, select=True,
              text=u'Basic')
        parent.AddPage(imageId=-1, page=self.scrolledWindow2, select=False,
              text=u'Other')

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_REGISTER, name=u'register',
              parent=prnt, pos=wx.Point(435, 163), size=wx.Size(709, 478),
              style=wx.DEFAULT_DIALOG_STYLE, title=u'register')
        self.SetClientSize(wx.Size(691, 433))

        self.notebook1 = wx.Notebook(id=wxID_REGISTERNOTEBOOK1,
              name='notebook1', parent=self, pos=wx.Point(8, 8),
              size=wx.Size(672, 376), style=0)

        self.submit = wx.Button(id=wx.ID_OK, label=u'submit', name=u'submit',
              parent=self, pos=wx.Point(128, 392), size=wx.Size(100, 31),
              style=0)
        self.submit.Bind(wx.EVT_BUTTON, self.OnSubmitButton,
              id=wxID_REGISTERSUBMIT)

        self.cancel = wx.Button(id=wx.ID_CANCEL, label=u'cancel',
              name=u'cancel', parent=self, pos=wx.Point(456, 392),
              size=wx.Size(100, 31), style=0)

        self.scrolledWindow1 = wx.ScrolledWindow(id=wxID_REGISTERSCROLLEDWINDOW1,
              name='scrolledWindow1', parent=self.notebook1, pos=wx.Point(0, 0),
              size=wx.Size(664, 345), style=wx.HSCROLL | wx.VSCROLL)

        self.panel1 = wx.Panel(id=wxID_REGISTERPANEL1, name='panel1',
              parent=self.scrolledWindow1, pos=wx.Point(-8, 112),
              size=wx.Size(664, 120), style=wx.TAB_TRAVERSAL)

        self.panel2 = wx.Panel(id=wxID_REGISTERPANEL2, name='panel2',
              parent=self.scrolledWindow1, pos=wx.Point(-8, 240),
              size=wx.Size(664, 100), style=wx.TAB_TRAVERSAL)

        self.panel3 = wx.Panel(id=wxID_REGISTERPANEL3, name='panel3',
              parent=self.scrolledWindow1, pos=wx.Point(0, 0), size=wx.Size(664,
              100), style=wx.TAB_TRAVERSAL)

        self.scrolledWindow2 = wx.ScrolledWindow(id=wxID_REGISTERSCROLLEDWINDOW2,
              name='scrolledWindow2', parent=self.notebook1, pos=wx.Point(0, 0),
              size=wx.Size(664, 345), style=wx.HSCROLL | wx.VSCROLL)

        self.pwd = wx.TextCtrl(id=wxID_REGISTERPWD, name=u'pwd',
              parent=self.panel3, pos=wx.Point(312, 16), size=wx.Size(136, 26),
              style=0, value=u'fdd')

        self.staticText1 = wx.StaticText(id=wxID_REGISTERSTATICTEXT1,
              label=u'pwd', name='staticText1', parent=self.panel3,
              pos=wx.Point(256, 16), size=wx.Size(26, 18), style=0)

        self.staticText2 = wx.StaticText(id=wxID_REGISTERSTATICTEXT2,
              label=u'name', name='staticText2', parent=self.panel3,
              pos=wx.Point(24, 56), size=wx.Size(37, 18), style=0)

        self.staticText4 = wx.StaticText(id=wxID_REGISTERSTATICTEXT4,
              label=u'phone', name='staticText4', parent=self.panel3,
              pos=wx.Point(24, 16), size=wx.Size(40, 18), style=0)

        self.phone = wx.TextCtrl(id=wxID_REGISTERPHONE, name=u'phone',
              parent=self.panel3, pos=wx.Point(80, 16), size=wx.Size(132, 26),
              style=0, value=u'')

        self.name = wx.TextCtrl(id=wxID_REGISTERNAME, name=u'name',
              parent=self.panel3, pos=wx.Point(80, 56), size=wx.Size(136, 26),
              style=0, value=u'')

        self.staticText3 = wx.StaticText(id=wxID_REGISTERSTATICTEXT3,
              label=u'email', name='staticText3', parent=self.panel1,
              pos=wx.Point(32, 32), size=wx.Size(41, 18), style=0)

        self.email = wx.TextCtrl(id=wxID_REGISTEREMAIL, name=u'email',
              parent=self.panel1, pos=wx.Point(88, 32), size=wx.Size(136, 26),
              style=0, value=u'test@iNeed.com')

        self.age = wx.TextCtrl(id=wxID_REGISTERAGE, name=u'age',
              parent=self.panel1, pos=wx.Point(320, 32), size=wx.Size(136, 26),
              style=0, value=u'')

        self.staticText5 = wx.StaticText(id=wxID_REGISTERSTATICTEXT5,
              label=u'age', name='staticText5', parent=self.panel1,
              pos=wx.Point(264, 32), size=wx.Size(24, 18), style=0)

        self.sex = wx.Choice(choices=['Male', 'Female'], id=wxID_REGISTERSEX,
              name=u'sex', parent=self.panel1, pos=wx.Point(88, 80),
              size=wx.Size(140, 26), style=0)

        self.staticText6 = wx.StaticText(id=wxID_REGISTERSTATICTEXT6,
              label=u'sex', name='staticText6', parent=self.panel1,
              pos=wx.Point(32, 80), size=wx.Size(23, 18), style=0)

        self.panel4 = wx.Panel(id=wxID_REGISTERPANEL4, name='panel4',
              parent=self.scrolledWindow2, pos=wx.Point(0, 0), size=wx.Size(664,
              64), style=wx.TAB_TRAVERSAL)

        self.staticText7 = wx.StaticText(id=wxID_REGISTERSTATICTEXT7,
              label=u'licenseID', name='staticText7', parent=self.panel4,
              pos=wx.Point(16, 16), size=wx.Size(58, 18), style=0)

        self.staticText9 = wx.StaticText(id=wxID_REGISTERSTATICTEXT9,
              label=u'company', name='staticText9', parent=self.panel4,
              pos=wx.Point(256, 16), size=wx.Size(60, 18), style=0)

        self.licenseID = wx.TextCtrl(id=wxID_REGISTERLICENSEID,
              name=u'licenseID', parent=self.panel4, pos=wx.Point(80, 16),
              size=wx.Size(136, 26), style=0, value=u'')

        self.company = wx.TextCtrl(id=wxID_REGISTERCOMPANY, name=u'company',
              parent=self.panel4, pos=wx.Point(328, 16), size=wx.Size(136, 26),
              style=0, value=u'')

        self.panel5 = wx.Panel(id=wxID_REGISTERPANEL5, name='panel5',
              parent=self.scrolledWindow2, pos=wx.Point(-8, 64),
              size=wx.Size(664, 168), style=wx.TAB_TRAVERSAL)

        self.staticText12 = wx.StaticText(id=wxID_REGISTERSTATICTEXT12,
              label=u'carID', name='staticText12', parent=self.panel5,
              pos=wx.Point(24, 8), size=wx.Size(36, 18), style=0)

        self.carID = wx.TextCtrl(id=wxID_REGISTERCARID, name=u'carID',
              parent=self.panel5, pos=wx.Point(88, 8), size=wx.Size(136, 26),
              style=0, value=u'')

        self.carColor = wx.Choice(choices=['white', 'yellow', 'red'],
              id=wxID_REGISTERCARCOLOR, name=u'carColor', parent=self.panel5,
              pos=wx.Point(336, 16), size=wx.Size(140, 26), style=0)

        self.brand = wx.Choice(choices=['Audi', 'Benci', 'Parsate', 'Santana'],
              id=wxID_REGISTERBRAND, name=u'brand', parent=self.panel5,
              pos=wx.Point(88, 64), size=wx.Size(140, 26), style=0)
        self.brand.SetSelection(1)

        self.staticText8 = wx.StaticText(id=wxID_REGISTERSTATICTEXT8,
              label=u'brand', name='staticText8', parent=self.panel5,
              pos=wx.Point(16, 64), size=wx.Size(37, 18), style=0)

        self.staticText10 = wx.StaticText(id=wxID_REGISTERSTATICTEXT10,
              label=u'carcolor', name='staticText10', parent=self.panel5,
              pos=wx.Point(256, 16), size=wx.Size(50, 18), style=0)

        self.panel6 = wx.Panel(id=wxID_REGISTERPANEL6, name='panel6',
              parent=self.scrolledWindow2, pos=wx.Point(-8, 240),
              size=wx.Size(664, 100), style=wx.TAB_TRAVERSAL)

        self.staticText11 = wx.StaticText(id=wxID_REGISTERSTATICTEXT11,
              label=u'This is only for driver now', name='staticText11',
              parent=self.panel6, pos=wx.Point(96, 16), size=wx.Size(168, 18),
              style=0)

        self._init_coll_notebook1_Pages(self.notebook1)

    def __init__(self, parent,role):
        self._init_ctrls(parent)
        self.role = role
    def OnSubmitButton(self, event):
        event.Skip()
        phone = self.phone.Value
        pwd = self.pwd.Value
        email = self.email.Value
        trueName = self.name.Value
        sex = self.sex.Selection==0
        age = self.age.Value
        licenseId = self.licenseID.Value
        company = self.company.Value
        carId = self.carID.Value
        carBrand = self.brand.Items[self.brand.Selection]
        carColor = self.carColor.Items[self.carColor.Selection]
        if self.role != EPR_DRIVER:
            database.registerUser(phone,pwd,email,trueName,sex,age)
        else:
            database.registerDriver(phone,pwd,email,trueName,sex,age,licenseId,company,carId,carBrand,carColor)
            
        
       
